import os
import cgi
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
from google.appengine.ext.webapp import template

os.environ['DJANGO_SETTINGS_MODULE'] = 'conf.settings'
from django.conf import settings
# Force Django to reload settings
settings._target = None

import models
import appengine_admin


class MainPage(webapp.RequestHandler):
	def get(self):
		template_values = {
			"buildtypes" : db.GqlQuery("Select * From BuildType"),
			"smiles" :	db.GqlQuery("Select * From SmilesType")
		}
		path = os.path.join(os.path.dirname(__file__), 'templates/full/constructor.tpl')    
		self.response.out.write(template.render(path, template_values))

application = webapp.WSGIApplication([
				('/', MainPage),
				(r'^(/admin)(.*)$', appengine_admin.Admin),
				],debug=True)
def main():  
	run_wsgi_app(application)

if __name__ == "__main__":
	main()